<%@ page import="pildemil.Participant" %>
<html>
    <head>
        <meta name="layout" content="main" />  
    </head>
    
    <body>		
    	<div data-role="page">
	        <div data-role="header" id="navigation" class="nav" data-theme="b">
	        	<h1>Participants</h1>
		        
		        <div data-role="navbar" class="nav">
			        <ul>
			        	<li><a href="/projet/editer" id="accueil" data-icon="custom">Accueil</a></li>
			        	<li><a href="/participant/liste" id="participants" data-icon="custom">Participants</a></li>
			        	<li><a href="/depense/liste" id="depenses" data-icon="custom">Dépenses</a></li>
			        	<li><a href="/transaction/liste" id="resultats" data-icon="custom">Résultats</a></li>
			        </ul>
		        </div>
	        </div>
	                
	        <div data-role="content" id="content">
		        <g:form name="formulaire" action="ajouter" data-transition="none">
				    <div data-role="fieldcontain">
					    <label for="nom"><em>* </em>Nom</label>
					    <g:textField name="nom" value="${participant?.nom}" minlength="3" maxlength="50" class="required" />
				    </div>
				    
					<g:submitButton name="ajouter" value="Ajouter" data-icon="check"/>
	            </g:form>
				
	        	<g:if test="${listeParticipant?.size() != 0}">	 	
				<ul data-role="listview" id="liste" data-inset="true">	
				    <g:each in="${listeParticipant}" status="i" var="participant">	
                    <li>
                    	<g:link action="editer" id="${participant?.key?.id}">
	                    	
	                    	<h3>${participant?.nom.encodeAsHTML()}</h3>
	                    	
	                    	<g:if test="${participant?.estResponsable}"><p>[Responsable de l'évènement]</p></g:if>
	                    	
	                    	<p>a dépensé ${participant?.totalDepense} €<p>
	                    	<p>a consommé ${participant?.totalConsommation} €<p>
	                    	<g:if test="${participant?.differentielVal > 0}">
	                    		<p class="positif">différentiel de ${participant?.differentiel} €<p>
	                    	</g:if>
	                    	<g:if test="${participant?.differentielVal < 0}">
	                    		<p class="negatif">différentiel de ${participant?.differentiel} €<p>
	                    	</g:if>
	                    	
                    		
	                    	<g:if test="${participant?.email == ''}">
	                    		<p>Pas d'e-mail renseigné</p>
                    		</g:if>
                    		<g:else>
                    			<p>${participant?.email.encodeAsHTML()}</p>
                    		</g:else>
                    		
                    		<span class="ui-li-count">${participant?.part}
                    			<g:if test="${participant?.part == 1}"> part</g:if>
                    			<g:else> parts</g:else>
                    		</span>
                    	</g:link>
                    	
                    	<g:link action="supprimer" id="${participant?.key?.id}" data-icon="delete"></g:link>
                    </li>
					</g:each>
				</ul>
				</g:if>
				
				<g:else>
				La liste des participants est vide. Cliquer sur "Ajouter" pour ajouter un nouveau participant. 
				</g:else>
	        </div>
	        
	        <script type="text/javascript">
    			$('[data-role=page]').live('pageshow', function () {   
  			    	$('#formulaire').validate();
  			    	$('#liste').listview('refresh');
  				});
	        </script>       
        </div>
    </body>
</html>
